<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="renderer" content="webkit">

    <title>推荐管理</title>

    <meta name="keywords" content="">
    <meta name="description" content="">

    <!--[if lt IE 9]>
    <meta http-equiv="refresh" content="0;ie.html" />
    <![endif]-->

    <link rel="shortcut icon" href="favicon.ico"> <link href="__STATIC__/css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
    <link href="__STATIC__/css/font-awesome.min.css?v=4.4.0" rel="stylesheet">
    <link href="__STATIC__/css/animate.css" rel="stylesheet">
    <link href="__STATIC__/css/style.css?v=4.1.0" rel="stylesheet">
    <style type="text/css">
        div{
            text-align: center;
        }
        th{
            text-align: center;
        }
        .fanye{
            text-align: center;
        }
        select:{
            width: auto;
            padding: 0;
            margin: 0;
        }
        select.form-control.m-b{
            text-align: center;
        }
        option{
            text-align: center;
        }
    </style>
</head>
<body>
    <div class="ibox-title">
        <h5 style="color: #f47;font-weight: bold;">热门搜索推荐</h5>
        <h6 style="color: #f47;">限定三个热门搜索（超过三个显示后三个）</h6>
    </div>

    <!-- 首页推荐 -->
    <div class="ibox-content ">
        <table class="table table-bordered ">
            <thead>
                <tr>
                    <th class="col-sm-1">推荐</th>
                    <th class="col-sm-1">榜单</th>
                    <th class="col-sm-1">茶类</th>
                    <th class="col-sm-1">产地</th>
                    <th class="col-sm-1">选择推荐</th>
                    <th class="col-sm-1"> 操作</th>
                </tr>
            </thead>
            <tbody>
                {notempty name="$list"}
                {foreach $list as $l}
                <form action="{:url('updaterecommended')}" method="post">
                <tr>
                    <td>{$l.list}</td>
                    <td>
                        <select class="form-control m-b" name="bangdan_id" value="" style="font-size: 12px; margin-bottom:0">
                        {foreach $resbandan as $bd}
                        <option value="{$bd['id']}" {if condition="$l.bangdan_id == $bd['id']"}selected='selected'{/if}>{$bd.bdname}</option>
                        {/foreach}
                        </select>
                    </td>
                    <td>
                        <select class="form-control m-b" value="{$l.teacase_id}" name="teacase_id" style="font-size: 12px; margin-bottom:0">
                        {foreach $teacase as $case}
                        <option value="{$case['id']}" {if condition="$l.teacase_id == $case['id']"}selected='selected'{/if}>{$case['teaname']}</option>
                        {/foreach}
                        </select>
                    </td>
                    <td class="area">
                        <select class="form-control m-b " name="teaarea_id"  value="{$l.teaarea_id}" style="font-size: 12px; margin-bottom:0">
                        <option value="0">总榜</option>
                        {foreach $l['area'] as $ra}
                        <option value="{$l.teaarea_id}" {if condition="$ra.aid == $l.teaarea_id"}selected='selected'{/if}>{$ra.aname}</option>
                        {/foreach}
                    </select>
                    </td>
                    <td>
                        {switch name="$l.list"}
                        {case value='1'}
                            <span class="btn btn-danger" onclick="bottonmove('{$l.Id}','{$l.list}','{$l.head}')">下移</span>
                        {/case}
                        {case value='2'}
                            <span class="btn btn-success" onclick="topmove('{$l.Id}','{$l.list}','{$l.head}')">上移</span>
                            <span class="btn btn-danger" onclick="bottonmove('{$l.Id}','{$l.list}','{$l.head}')">下移</span>
                        {/case}
                        {case value='3'}
                            <span class="btn btn-success" onclick="topmove('{$l.Id}','{$l.list}','{$l.head}')">上移</span>
                        {/case}
                        {/switch}
                    </td>
                    <input type="test" name="last_list" value="{$l.list}" style="display: none;">
                    <input type="text" name="id" value="{$l.Id}" style="display: none;">
                    <td>
                        <button class="btn btn-primary" id="s1" type="submit" >修改推荐</button>
                    </td>
                </tr>
                </form>
                {/foreach}
                {/notempty}
            </tbody>
        </table>
    </div>
 
    <!-- 1红茶 -->
    <div class="ibox-content ">
        <div style="font-weight: bold;color: #f47">红茶</div>
        <table class="table table-bordered ">
            <thead>
                <tr>
                    <th class="col-sm-1">推荐</th>
                    <th class="col-sm-1">榜单</th>
                    <th class="col-sm-1">产地</th>
                    <th class="col-sm-1">选择推荐</th>
                    <th class="col-sm-1"> 操作</th>
                </tr>
            </thead>
            <tbody>
                {notempty name="$list1"}
                {foreach $list1 as $l1}
                <form action="{:url('updaterecommended')}" method="post">
                <tr>
                    <td>{$l1.list}</td>
                    <td>
                        <select class="form-control m-b" name="bangdan_id" value="" style="font-size: 12px; margin-bottom:0">
                        {foreach $resbandan as $bd}
                        <option value="{$bd['id']}" {if condition="$l1.bangdan_id == $bd['id']"}selected='selected'{/if}>{$bd.bdname}</option>
                        {/foreach}
                        </select>
                    </td>
                    <td class="area">
                        <select class="form-control m-b " name="teaarea_id"  value="{$l1.teaarea_id}" style="font-size: 12px; margin-bottom:0">
                        <option value="0">总榜</option>
                        {foreach $l1['area'] as $ra}
                        <option value="{$l1.teaarea_id}" {if condition="$ra.aid == $l1.teaarea_id"}selected='selected'{/if}>{$ra.aname}</option>
                        {/foreach}
                    </select>
                    </td>
                    <td>
                       {switch name="$l1.list"}
                        {case value='1'}
                            <span class="btn btn-danger" onclick="bottonmove('{$l1.Id}','{$l1.list}','{$l1.head}')">下移</span>
                        {/case}
                        {case value='2'}
                            <span class="btn btn-success" onclick="topmove('{$l1.Id}','{$l1.list}','{$l1.head}')">上移</span>
                            <span class="btn btn-danger" onclick="bottonmove('{$l1.Id}','{$l1.list}','{$l1.head}')">下移</span>
                        {/case}
                        {case value='3'}
                            <span class="btn btn-success" onclick="topmove('{$l1.Id}','{$l1.list}','{$l1.head}')">上移</span>
                        {/case}
                        {/switch}
                    </td>
                    <input type="test" name="teacase_id" value="{$l1.teacase_id}" style="display: none;">
                    <input type="test" name="last_list" value="{$l1.list}" style="display: none;">
                    <input type="text" name="id" value="{$l1.Id}" style="display: none;">
                    <td>
                        <button class="btn btn-primary" id="s1" type="submit" >修改推荐</button>
                    </td>
                </tr>
                </form>
                {/foreach}
                {/notempty}
                    <td colspan="5">
                        <span onclick="get_hot(1)" class="btn btn-primary" id="s1" type="submit" >获取热门排行</span>
                    </td>
            </tbody>
        </table>
    </div>
    
    <!-- 2绿茶 -->
    <div class="ibox-content ">
        <div style="font-weight: bold;color: green">绿茶</div>
        <table class="table table-bordered ">
            <thead>
                <tr>
                    <th class="col-sm-1">推荐</th>
                    <th class="col-sm-1">榜单</th>
                    <th class="col-sm-1">产地</th>
                    <th class="col-sm-1">选择推荐</th>
                    <th class="col-sm-1"> 操作</th>
                </tr>
            </thead>
            <tbody>
                {notempty name="$list2"}
                {foreach $list2 as $l2}
                <form action="{:url('updaterecommended')}" method="post">
                <tr>
                    <td>{$l2.list}</td>
                    <td>
                        <select class="form-control m-b" name="bangdan_id" value="" style="font-size: 12px; margin-bottom:0">
                        {foreach $resbandan as $bd}
                        <option value="{$bd['id']}" {if condition="$l2.bangdan_id == $bd['id']"}selected='selected'{/if}>{$bd.bdname}</option>
                        {/foreach}
                        </select>
                    </td>
                    <td class="area">
                        <select class="form-control m-b " name="teaarea_id"  value="{$l2.teaarea_id}" style="font-size: 12px; margin-bottom:0">
                        <option value="0">总榜</option>
                        {foreach $l2['area'] as $ra}
                        <option value="{$l2.teaarea_id}" {if condition="$ra.aid == $l2.teaarea_id"}selected='selected'{/if}>{$ra.aname}</option>
                        {/foreach}
                    </select>
                    </td>
                    <td>
                        {switch name="$l2.list"}
                        {case value='1'}
                            <span class="btn btn-danger" onclick="bottonmove('{$l2.Id}','{$l2.list}','{$l2.head}')">下移</span>
                        {/case}
                        {case value='2'}
                            <span class="btn btn-success" onclick="topmove('{$l2.Id}','{$l2.list}','{$l2.head}')">上移</span>
                            <span class="btn btn-danger" onclick="bottonmove('{$l2.Id}','{$l2.list}','{$l2.head}')">下移</span>
                        {/case}
                        {case value='3'}
                            <span class="btn btn-success" onclick="topmove('{$l2.Id}','{$l2.list}','{$l2.head}')">上移</span>
                        {/case}
                        {/switch}
                    </td>
                    <input type="test" name="teacase_id" value="{$l1.teacase_id}" style="display: none;">
                    <input type="test" name="last_list" value="{$l2.list}" style="display: none;">
                    <input type="text" name="id" value="{$l2.Id}" style="display: none;">
                    <td>
                        <button class="btn btn-primary" id="s1" type="submit" >修改推荐</button>
                    </td>
                </tr>
                </form>
                {/foreach}
                {/notempty}
                <td colspan="5">
                        <span onclick="get_hot(2)" class="btn btn-primary" id="s1" type="submit" >获取热门排行</span>
                    </td>
            </tbody>
        </table>
    </div>
    
    <!-- 3白茶 -->
    <div class="ibox-content ">
        <div style="font-weight: bold;">白茶</div>
        <table class="table table-bordered ">
            <thead>
                <tr>
                    <th class="col-sm-1">推荐</th>
                    <th class="col-sm-1">榜单</th>
                    <th class="col-sm-1">产地</th>
                    <th class="col-sm-1">选择推荐</th>
                    <th class="col-sm-1"> 操作</th>
                </tr>
            </thead>
            <tbody>
                {notempty name="$list3"}
                {foreach $list3 as $l3}
                <form action="{:url('updaterecommended')}" method="post">
                <tr>
                    <td>{$l3.list}</td>
                    <td>
                        <select class="form-control m-b" name="bangdan_id" value="" style="font-size: 12px; margin-bottom:0">
                        {foreach $resbandan as $bd}
                        <option value="{$bd['id']}" {if condition="$l3.bangdan_id == $bd['id']"}selected='selected'{/if}>{$bd.bdname}</option>
                        {/foreach}
                        </select>
                    </td>
                    <td class="area">
                        <select class="form-control m-b " name="teaarea_id"  value="{$l3.teaarea_id}" style="font-size: 12px; margin-bottom:0">
                        <option value="0">总榜</option>
                        {foreach $l3['area'] as $ra}
                        <option value="{$l3.teaarea_id}" {if condition="$ra.aid == $l3.teaarea_id"}selected='selected'{/if}>{$ra.aname}</option>
                        {/foreach}
                    </select>
                    </td>
                    <td>
                        {switch name="$l3.list"}
                        {case value='1'}
                            <span class="btn btn-danger" onclick="bottonmove('{$l3.Id}','{$l3.list}','{$l3.head}')">下移</span>
                        {/case}
                        {case value='2'}
                            <span class="btn btn-success" onclick="topmove('{$l3.Id}','{$l3.list}','{$l3.head}')">上移</span>
                            <span class="btn btn-danger" onclick="bottonmove('{$l3.Id}','{$l3.list}','{$l3.head}')">下移</span>
                        {/case}
                        {case value='3'}
                            <span class="btn btn-success" onclick="topmove('{$l3.Id}','{$l3.list}','{$l3.head}')">上移</span>
                        {/case}
                        {/switch}
                    </td>
                    <input type="test" name="teacase_id" value="{$l1.teacase_id}" style="display: none;">
                    <input type="test" name="last_list" value="{$l3.list}" style="display: none;">
                    <input type="text" name="id" value="{$l3.Id}" style="display: none;">
                    <td>
                        <button class="btn btn-primary" id="s1" type="submit" >修改推荐</button>
                    </td>
                </tr>
                </form>
                {/foreach}
                {/notempty}
                <td colspan="5">
                        <span onclick="get_hot(3)" class="btn btn-primary" id="s1" type="submit" >获取热门排行</span>
                    </td>
            </tbody>
        </table>
    </div>
    
    <!-- 4普洱茶 -->
    <div class="ibox-content ">
        <div style="font-weight: bold;">普洱茶</div>
        <table class="table table-bordered ">
            <thead>
                <tr>
                    <th class="col-sm-1">推荐</th>
                    <th class="col-sm-1">榜单</th>
                    <th class="col-sm-1">产地</th>
                    <th class="col-sm-1">选择推荐</th>
                    <th class="col-sm-1"> 操作</th>
                </tr>
            </thead>
            <tbody>
                {notempty name="$list4"}
                {foreach $list4 as $l4}
                <form action="{:url('updaterecommended')}" method="post">
                <tr>
                    <td>{$l4.list}</td>
                    <td>
                        <select class="form-control m-b" name="bangdan_id" value="" style="font-size: 12px; margin-bottom:0">
                        {foreach $resbandan as $bd}
                        <option value="{$bd['id']}" {if condition="$l4.bangdan_id == $bd['id']"}selected='selected'{/if}>{$bd.bdname}</option>
                        {/foreach}
                        </select>
                    </td>
                    <td class="area">
                        <select class="form-control m-b " name="teaarea_id"  value="{$l4.teaarea_id}" style="font-size: 12px; margin-bottom:0">
                        <option value="0">总榜</option>
                        {foreach $l4['area'] as $ra}
                        <option value="{$l4.teaarea_id}" {if condition="$ra.aid == $l4.teaarea_id"}selected='selected'{/if}>{$ra.aname}</option>
                        {/foreach}
                    </select>
                    </td>
                    <td>
                        {switch name="$l4.list"}
                        {case value='1'}
                            <span class="btn btn-danger" onclick="bottonmove('{$l4.Id}','{$l4.list}','{$l4.head}')">下移</span>
                        {/case}
                        {case value='2'}
                            <span class="btn btn-success" onclick="topmove('{$l4.Id}','{$l4.list}','{$l4.head}')">上移</span>
                            <span class="btn btn-danger" onclick="bottonmove('{$l4.Id}','{$l4.list}','{$l4.head}')">下移</span>
                        {/case}
                        {case value='3'}
                            <span class="btn btn-success" onclick="topmove('{$l4.Id}','{$l4.list}','{$l4.head}')">上移</span>
                        {/case}
                        {/switch}
                    </td>
                    <input type="test" name="teacase_id" value="{$l1.teacase_id}" style="display: none;">
                    <input type="test" name="last_list" value="{$l4.list}" style="display: none;">
                    <input type="text" name="id" value="{$l4.Id}" style="display: none;">
                    <td>
                        <button class="btn btn-primary" id="s1" type="submit" >修改推荐</button>
                    </td>
                </tr>
                </form>
                {/foreach}
                {/notempty}
                <td colspan="5">
                        <span onclick="get_hot(4)" class="btn btn-primary" id="s1" type="submit" >获取热门排行</span>
                    </td>
            </tbody>
        </table>
    </div>
    
    <!-- 5乌龙茶 -->
    <div class="ibox-content ">
        <div style="font-weight: bold;">乌龙茶</div>
        <table class="table table-bordered ">
            <thead>
                <tr>
                    <th class="col-sm-1">推荐</th>
                    <th class="col-sm-1">榜单</th>
                    <th class="col-sm-1">产地</th>
                    <th class="col-sm-1">选择推荐</th>
                    <th class="col-sm-1"> 操作</th>
                </tr>
            </thead>
            <tbody>
                {notempty name="$list5"}
                {foreach $list5 as $l5}
                <form action="{:url('updaterecommended')}" method="post">
                <tr>
                    <td>{$l5.list}</td>
                    <td>
                        <select class="form-control m-b" name="bangdan_id" value="" style="font-size: 12px; margin-bottom:0">
                        {foreach $resbandan as $bd}
                        <option value="{$bd['id']}" {if condition="$l5.bangdan_id == $bd['id']"}selected='selected'{/if}>{$bd.bdname}</option>
                        {/foreach}
                        </select>
                    </td>
                    <td class="area">
                        <select class="form-control m-b " name="teaarea_id"  value="{$l5.teaarea_id}" style="font-size: 12px; margin-bottom:0">
                        <option value="0">总榜</option>
                        {foreach $l5['area'] as $ra}
                        <option value="{$l5.teaarea_id}" {if condition="$ra.aid == $l5.teaarea_id"}selected='selected'{/if}>{$ra.aname}</option>
                        {/foreach}
                    </select>
                    </td>
                    <td>
                        {switch name="$l5.list"}
                        {case value='1'}
                            <span class="btn btn-danger" onclick="bottonmove('{$l5.Id}','{$l5.list}','{$l5.head}')">下移</span>
                        {/case}
                        {case value='2'}
                            <span class="btn btn-success" onclick="topmove('{$l5.Id}','{$l5.list}','{$l5.head}')">上移</span>
                            <span class="btn btn-danger" onclick="bottonmove('{$l5.Id}','{$l5.list}','{$l5.head}')">下移</span>
                        {/case}
                        {case value='3'}
                            <span class="btn btn-success" onclick="topmove('{$l5.Id}','{$l5.list}','{$l5.head}')">上移</span>
                        {/case}
                        {/switch}
                    </td>
                    <input type="test" name="teacase_id" value="{$l1.teacase_id}" style="display: none;">
                    <input type="test" name="last_list" value="{$l5.list}" style="display: none;">
                    <input type="text" name="id" value="{$l5.Id}" style="display: none;">
                    <td>
                        <button class="btn btn-primary" id="s1" type="submit" >修改推荐</button>
                    </td>
                </tr>
                </form>
                {/foreach}
                {/notempty}
                <td colspan="5">
                        <span onclick="get_hot(5)" class="btn btn-primary" id="s1" type="submit" >获取热门排行</span>
                    </td>
            </tbody>
        </table>
    </div>

    <!-- 6黑茶 -->
    <div class="ibox-content ">
        <div style="font-weight: bold;">黑茶</div>
        <table class="table table-bordered ">
            <thead>
                <tr>
                    <th class="col-sm-1">推荐</th>
                    <th class="col-sm-1">榜单</th>
                    <th class="col-sm-1">产地</th>
                    <th class="col-sm-1">选择推荐</th>
                    <th class="col-sm-1"> 操作</th>
                </tr>
            </thead>
            <tbody>
                {notempty name="$list6"}
                {foreach $list6 as $l6}
                <form action="{:url('updaterecommended')}" method="post">
                <tr>
                    <td>{$l6.list}</td>
                    <td>
                        <select class="form-control m-b" name="bangdan_id" value="" style="font-size: 12px; margin-bottom:0">
                        {foreach $resbandan as $bd}
                        <option value="{$bd['id']}" {if condition="$l6.bangdan_id == $bd['id']"}selected='selected'{/if}>{$bd.bdname}</option>
                        {/foreach}
                        </select>
                    </td>
                    <td class="area">
                        <select class="form-control m-b " name="teaarea_id"  value="{$l6.teaarea_id}" style="font-size: 12px; margin-bottom:0">
                        <option value="0">总榜</option>
                        {foreach $l6['area'] as $ra}
                        <option value="{$l6.teaarea_id}" {if condition="$ra.aid == $l6.teaarea_id"}selected='selected'{/if}>{$ra.aname}</option>
                        {/foreach}
                    </select>
                    </td>
                    <td>
                        {switch name="$l6.list"}
                        {case value='1'}
                            <span class="btn btn-danger" onclick="bottonmove('{$l6.Id}','{$l6.list}','{$l6.head}')">下移</span>
                        {/case}
                        {case value='2'}
                            <span class="btn btn-success" onclick="topmove('{$l6.Id}','{$l6.list}','{$l6.head}')">上移</span>
                            <span class="btn btn-danger" onclick="bottonmove('{$l6.Id}','{$l6.list}','{$l6.head}')">下移</span>
                        {/case}
                        {case value='3'}
                            <span class="btn btn-success" onclick="topmove('{$l6.Id}','{$l6.list}','{$l6.head}')">上移</span>
                        {/case}
                        {/switch}
                    </td>
                    <input type="test" name="teacase_id" value="{$l1.teacase_id}" style="display: none;">
                    <input type="test" name="last_list" value="{$l6.list}" style="display: none;">
                    <input type="text" name="id" value="{$l6.Id}" style="display: none;">
                    <td>
                        <button class="btn btn-primary" id="s1" type="submit" >修改推荐</button>
                    </td>
                </tr>
                </form>
                {/foreach}
                {/notempty}
                    <td colspan="5">
                        <span onclick="get_hot(6)" class="btn btn-primary" id="s1" type="submit" >获取热门排行</span>
                    </td>
            </tbody>
        </table>
    </div>
    
    
<!-- 全局js -->
<script src="__STATIC__/js/jquery.min.js?v=2.1.4"></script>
<script src="__STATIC__/js/bootstrap.min.js?v=3.3.6"></script>
<script src="__STATIC__/js/plugins/metisMenu/jquery.metisMenu.js"></script>
<script src="__STATIC__/js/plugins/slimscroll/jquery.slimscroll.min.js"></script>
<script src="__STATIC__/js/plugins/layer/layer.min.js"></script>

<!-- 自定义js -->
<script src="__STATIC__/js/hAdmin.js?v=4.1.0"></script>
<script type="text/javascript" src="__STATIC__/js/index.js"></script>

<!-- 第三方插件 -->
<script src="__STATIC__/js/plugins/pace/pace.min.js"></script>
<script type="text/javascript">
    $("select[name=teacase_id]").change(function(){
        var val = $(this).find("option:selected").attr("value");
        var area = $(this).parent().parent().find('.area').find('select[name=teaarea_id]');
        var url="{:url('reTeaAreaJson')}";
        $.post(url, {teacase_id:val},function(data){
            var areas = JSON.parse(data);
            var option="<option value='0'>总榜</option>";
            for(var index in areas){
                // console.log(areas[index]["area"])
                var a = "<option value="+areas[index]['id']+">"+areas[index]['area']+"</option>"
                option +=a
            }
            // console.log(area);
            area.html("")
            area.html(option)
        })
    })
    function topmove(id,list,head){
        var url="{:url('update_top_list')}";
        // console.log(id+","+list+","+head)
        $.post(url,{list:list,id:id,head:head},function(data){
            if(data==1){
                location.reload()
            }
        })   
    }
    function bottonmove(id,list,head){
        var url="{:url('update_botton_list')}";
        // console.log(id+","+list+","+head)
        $.post(url,{list:list,id:id,head:head},function(data){
            if(data==1){
                location.reload()
            }
        })   
    }
    function get_hot(id){
        var url = "{:url('get_hot_array')}";
        $.post(url,{teacase_id:id},function(data){
            if(data==1){
                location.reload()
            }else{
                alert("获取失败");
            }
        })
    }
    // $('select[name=list]').change(function(){
    //     var url="{:url('updatelist')}";
    //     var val = $(this).find("option:selected").attr("value");
    //     var id = $(this).attr('data-id');
    //     $.post(url, {list:val,id:id},function(data){
    //         if(data==1){
    //             location.reload()
    //         }
    //     })
    // })
</script>

</body>
</html>